import { crowdList } from '@/services/crowd';

export default {
  namespace: 'crowd',

  state: {
    list: [],
    pagination:[]
  },

  effects: {
    *fetchCrowdList({ payload }, { call, put }) {
      const response = yield call(crowdList, payload);
      if(response && response.status === 'success'){
        yield put({
            type: 'crowdList',
            payload: response.data,
          });
      }
    },
  },

  reducers: {
    crowdList(state, action) {
      return {
        ...state,
        list: action.payload.list,
        pagination: action.payload.pagination
      };
    },
  },
};
